﻿using DryWCS.Model.Stacker;
using DryWCS.Service.DbContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DryWCS.Service.Stacker
{
    public class StackerTaskHisService : LocalDbContext<StackerTaskHisEntity>
    {
        public List<StackerTaskHisEntity> GetListByTime(DateTime startTime, DateTime endTime)
        {
            try
            {
                return Db.Queryable<StackerTaskHisEntity>().Where(p => p.EndTime >= startTime && p.EndTime <= endTime).OrderBy(p => p.Id).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public List<StackerTaskHisEntity> GetListByLike(string search)
        {
            try
            {
                return Db.Queryable<StackerTaskHisEntity>()
                    .Where(p =>
                     p.WMSOrderId.ToString().Contains(search)
                    || p.TaskType.ToString().Contains(search)
                    || p.Status.ToString().Contains(search)
                    || p.StartMachineID.ToString().Contains(search)
                    || p.StartLineNo.ToString().Contains(search)
                    || p.StartColNo.ToString().Contains(search)
                    || p.StartLayerNo.ToString().Contains(search)
                    || p.EndMachineID.ToString().Contains(search)
                    || p.EndLineNo.ToString().Contains(search)
                    || p.EndColNo.ToString().Contains(search)
                    || p.EndLayerNo.ToString().Contains(search)
                    || p.MaterialCode.Contains(search)

                    ).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
